package com.jf.cloud.service.sysmanager.dao.impl;

import java.util.List;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;

import com.jf.cloud.service.sysmanager.common.base.BaseService;
import com.jf.cloud.service.sysmanager.common.db.BaseDao;
import com.jf.cloud.service.sysmanager.dao.ICardBatchService;
import com.jf.cloud.service.sysmanager.entity.CardBatchStatisticsView;

/**
 * Created with IntelliJ IDEA.
 * User: LangK
 * Created Date 2018/5/28
 * Time: 14:25
 * Description:
 */
@Service
public class CardBatchServiceImpl extends BaseService<CardBatchStatisticsView, Long> implements ICardBatchService {

    /**
     * 日志
     */
    private static Log log = LogFactory.getLog(CardBatchServiceImpl.class);

    /**
     * JDBC 模板
     */
    @Autowired
    private JdbcTemplate jdbcTemplate;
    
    @Autowired
    private BaseDao baseDao;


    @Override
    public List findAll() {
        String sql = "select * from card_view_batch_statistics";
        List<CardBatchStatisticsView> list = jdbcTemplate.query(sql  , new BeanPropertyRowMapper<>(CardBatchStatisticsView.class));
        return list;
    }

    @Override
    public List<Map<String,Object>> findNew() {
        String sql = "SELECT PLATFORM_TYPE AS 'value',PROJECT_NAME AS label FROM card_view_batch_statistics WHERE BATCH_ID IN (SELECT MAX(BATCH_ID) FROM card_view_batch_statistics GROUP BY PLATFORM_TYPE)";
        List<Map<String,Object>> list = baseDao.findMapList(sql);
        return list;
    }
}
